package com.ecfront.dao.impl;

import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.springframework.context.ApplicationContext;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.ecfront.dao.WebSiteDAO;
import com.ecfront.pojo.WebSite;

/**
 * @version 1.0
 * @author www.ecfrom.com
 */

public class WebSiteDAOImpl extends HibernateDaoSupport implements WebSiteDAO {

	protected void initDao() {}

	public void save(WebSite transientInstance) {
		getHibernateTemplate().saveOrUpdate(transientInstance);
	}

	public void delete(WebSite persistentInstance) {
		getHibernateTemplate().delete(persistentInstance);
	}

	public WebSite findById(java.lang.Integer id) {
		WebSite instance = (WebSite) getHibernateTemplate().get(
					"com.ecfront.pojo.WebSite", id);
		return instance;
	}

	public List findByExample(WebSite instance) {
		List results = getHibernateTemplate().findByExample(instance);
		return results;
	}

	public List findByProperty(String propertyName, Object value) {
		String queryString = "from WebSite as model where model."
					+ propertyName + "= ?";
		return getHibernateTemplate().find(queryString, value);
	}

	public List findByWname(Object wname) {
		return findByProperty(WNAME, wname);
	}
	public List findByWlogoUrl(Object wlogoUrl) {
		return findByProperty(WLOGO_URL, wlogoUrl);
	}

	public List findByWadd(Object wadd) {
		return findByProperty(WADD, wadd);
	}

	public List findByWphone(Object wphone) {
		return findByProperty(WPHONE, wphone);
	}

	public List findByWicp(Object wicp) {
		return findByProperty(WICP, wicp);
	}

	public List findByWemail(Object wemail) {
		return findByProperty(WEMAIL, wemail);
	}

	public List findByWinfo(Object winfo) {
		return findByProperty(WINFO, winfo);
	}

	public List findByWcompany(Object wcompany) {
		return findByProperty(WCOMPANY, wcompany);
	}

	public List findByWcompanySiteUrl(Object wcompanySiteUrl) {
		return findByProperty(WCOMPANY_SITE_URL, wcompanySiteUrl);
	}

	public List findByWconpanyInfo(Object wconpanyInfo) {
		return findByProperty(WCONPANY_INFO, wconpanyInfo);
	}

	public List findByWsmtpName(Object wsmtpName) {
		return findByProperty(WSMTP_NAME, wsmtpName);
	}

	public List findByWsmtpPwd(Object wsmtpPwd) {
		return findByProperty(WSMTP_PWD, wsmtpPwd);
	}

	public List findByWpayNbr(Object wpayNbr) {
		return findByProperty(WPAY_NBR, wpayNbr);
	}

	public List findByWshowGoodsTime(Object wshowGoodsTime) {
		return findByProperty(WSHOW_GOODS_TIME, wshowGoodsTime);
	}

	public List findAll() {
		String queryString = "from WebSite";
		return getHibernateTemplate().find(queryString);
	}

	public static WebSiteDAO getFromApplicationContext(ApplicationContext ctx) {
		return (WebSiteDAO) ctx.getBean("WebsiteDAO");
	}
}